package com.zpark.service.impl;

import com.zpark.entity.Product;
import com.zpark.mapper.SearchMapper;
import com.zpark.service.ISearchService;
import com.zpark.service.ex.FindAllProductNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SearchServiceImpl implements ISearchService {
    @Autowired
    private SearchMapper searchMapper;


    @Override
    public List<Product> SearchBytitle(String title) {
        List<Product> result = searchMapper.findProductsByName(title);
        if (result == null){
            throw new FindAllProductNotFoundException("没有找到该商品信息！");
        }
        return result;
    }
}
